package org.xue.snowmall.live.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.xue.snowmall.live.entity.LiveRecordEntity;
import org.xue.snowmall.live.service.LiveRecordService;
import org.xue.snowmall.common.utils.PageUtils;
import org.xue.snowmall.common.utils.R;
import org.xue.snowmall.live.vo.RelationVo;


/**
 * 
 *
 * @author zy
 * @email 2067065884@qq.com
 * @date 2021-09-29 14:42:28
 */
@RestController
@RequestMapping("live/liverecord")
public class LiveRecordController {
    @Autowired
    private LiveRecordService liveRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = liveRecordService.queryPage(params);

        return R.ok().put("page", page);
    }

    @PostMapping("/saveLiveRecord")
    public R saveLiveRecord(@RequestBody List<RelationVo> formList) {
        return liveRecordService.saveLiveRecord(formList);
    }
    /**
     * 信息
     */
    @RequestMapping("/info/{gsmLiveRecordId}")
    public R info(@PathVariable("gsmLiveRecordId") Long gsmLiveRecordId){
		LiveRecordEntity liveRecord = liveRecordService.getById(gsmLiveRecordId);

        return R.ok().put("liveRecord", liveRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody LiveRecordEntity liveRecord){
		liveRecordService.save(liveRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody LiveRecordEntity liveRecord){
		liveRecordService.updateById(liveRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] gsmLiveRecordIds){
		liveRecordService.removeByIds(Arrays.asList(gsmLiveRecordIds));

        return R.ok();
    }

}
